#include <bits/stdc++.h>
const int maxn = 1e6 + 10;
using namespace std;
int head[maxn],to[maxn],nex[maxn],v[maxn],k;
#define add(x,y,z); nex[++k]=head[x];\
to[k]=y;\
head[x]=k;\
v[k]=z;
int n,m,x,y,z,cnt = 1;
int maxx;
int f[maxn],g[maxn][3],node, vis[maxn], size[maxn];
void dfs(int num,int pre){  
	f[num] = 0;
	int max1, max2;
	max1 = max2 = 0;
	for(int i=head[num];i!=-1;i=nex[i])
        if(to[i]!=pre){
            dfs(to[i],num);
            if(f[to[i]]+v[i]>max1){
            	max2=max1; g[num][2]=g[num][1];
            	max1=f[to[i]]+v[i];
            	g[num][1]=to[i];
			}
			else if(f[to[i]]+v[i]>max2){
				max2=f[to[i]]+v[i];
            	g[num][2]=to[i];
			}
            f[num]=max(f[to[i]]+v[i],f[num]);
        }
    if(max1+max2>maxx){
    	maxx=max1+max2;
    	node=num;
	}
    return;
}
void dfs1(int x) {
	 vis[x] = true;
	 size[cnt] ++;
	 for(int i = head[x]; ~i; i = nex[i]) {
	 	int j = to[i];
	 	if(!vis[j]) {
		 	dfs1(j);
		 }
	 }
}
int main(){
    memset(head,-1,sizeof(head));
    scanf("%d",&n);
    for(int i=1;i<n;i++){
        scanf("%d%d",&x,&y);
		add(x,y,1);
        add(y,x,1);
    }
    maxx=0;
    dfs(1,0);
    int i;
    //printf("%d",node);
    i=node;
    while(i){
    	vis[i] = true;
    	i=g[i][1];
	}
	i=g[node][2];
    while(i){
    	vis[i] = true;
    	cout << i << endl;
	}
    int ans = 0;
    for (int i = 1; i <= n; i++){
		if(!vis[i]){
			dfs1(i);
			cnt ++;
		}
	}
	for (int i = 1; i < cnt;i++) {
		ans = max(ans, size[i]);
	}
	if(!ans)cout << 1 << endl;
	else cout << ans << endl;
    return 0;
}
